package com.ruoyi.common.core.enums;


import com.ruoyi.common.core.constant.constant.CodeConstant;

public enum ResultEnum implements BaseEnum {
    SUCCESS(CodeConstant.SUCCESS, "操作成功"),
    LOGIN(CodeConstant.LOGIN, "登录失效,请重新登录。"),
    LOGIN_PARAM(CodeConstant.FAIL, "账号或密码错误"),
    FAIL(CodeConstant.FAIL, "操作失败"),
    FAIL_STRATEGY(CodeConstant.FAIL, "未知策略,请联系管理员!"),
    FAIL_PARAM(CodeConstant.FAIL_PARAM, "参数错误!"),
    FAIL_CODE_PARAM(CodeConstant.FAIL_PARAM, "验证码错误!"),
    FAIL_REQUEST_SOURCE(CodeConstant.FAIL_PARAM, "请求来源不正确,请重新尝试!"),
    FAIL_REQUEST_REPETITION(CodeConstant.FAIL_REQUEST_REPETITION, "请求太快了,请稍后重试~"),
    FAIL_REQUEST_LIMIT(CodeConstant.FAIL_REQUEST_LIMIT, "当前访问过于频繁,请稍后重试~"),
    FAIL_REQUEST_QUEUE(CodeConstant.FAIL_REQUEST_QUEUE, "当前获取排队人数过多,请稍后重试~"),
    FAIL_REQUEST_PERMISSIONS(CodeConstant.FAIL_PERMISSIONS, "暂无访问权限,请联系管理员进行授权~"),
    ERROR(CodeConstant.ERROR, "服务器错误,请联系管理员!"),
    ERROR_SUFFIX(CodeConstant.ERROR, "后缀空指针异常,请联系管理员!"),
    BANNED(CodeConstant.BANNED, "此账号已被封禁,请联系管理员!"),
    ERROR_NETWORK(CodeConstant.ERROR_NETWORK, "服务网络异常,请联系管理员!"),
    ;

    ResultEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    String code;
    String message;

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public void setMessage(String message) {
        this.message = message;
    }

    public static ResultEnum messageResultEnum(String message) {
        for (ResultEnum value : ResultEnum.values()) {
            if (value.getMessage().equals(message)) {
                return value;
            }
        }
        return ResultEnum.ERROR;
    }
}
